/*
 * Customer.cpp
 *
 *  Created on: 2011-10-30
 *      Author: mateusz
 */

#include "Customer.h"
#include "CVRP.h"
#include <utility>

// depot definition
extern Depot* depot;

using namespace std;

Customer::Customer(int inputId, double x, double y, int demand) {
	double add=0;

	this->inputId = inputId; // set input order
	this->x = x; // x coordinate
	this->y = y; // y coordinate
	this->demand = demand; // customer's demand
	this->visited = false; // customer was not visited
	this->depotDistance = CVRP::distance(depot->getXY(), make_pair(x, y)); // distance to depot
	this->depotAngle = CVRP::angle(depot->getXY(), make_pair(x,y));

	if(x >= 0 && y >= 0){
		add = -2;
	}
	else if(x < 0 && y >= 0){
		add = -1;
	}
	else if(x < 0 && y < 0){
		add = 0;
	}
	else if(x >= 0 && y < 0){
		add = 1;
	}
	this->depotAngle += add;

	//printf("Customer(%d): (x,y) = (%lf, %lf); depotDistance = %lf, depotAngle = %lf\n", inputId, x, y, depotDistance, depotAngle);
}

Customer::~Customer() {
}

int Customer::getDemand() {
	return this->demand;
}

void Customer::visit() {
	this->visited = true;
}

void Customer::unvisit() {
	this->visited = false;
}

bool Customer::isVisited() {
	return this->visited;
}

void Customer::setId(int id) {
	this->id = id;
}

int Customer::getId() {
	return this->id;
}

int Customer::getInputId() {
	return this->inputId;
}

double Customer::getDepotDistance() {
	return this->depotDistance;
}

double Customer::getDepotAngle() {
	return this->depotAngle;
}

/**
 * set distance to closest vertex
 */
void Customer::setMinVertexDistance(double distance) {
	this->minVertexDistance = distance;
}

double Customer::getMinVertexDistance() {
	return this->minVertexDistance;
}
